#ifndef _BLOCK_H_
#define _BLOCK_H_

#include "vector.h"
#include <list>
#include "config.h"


class block
{
public:
	//enum
	enum block_shape
	{
		SHAPE_I = 0,
		SHAPE_LL,
		SHAPE_LR,
		SHAPE_ZL,
		SHAPE_ZR,
		SHAPE_E,
		SHAPE_O,
		MAX_SHAPE
	};

	enum block_color
	{
		COLOR_RED = 1,
		COLOR_GREEN,
		COLOR_BLUE,
		MAX_COLOR,
	};

	static void refine(vec2& point);

	block(vec2& pos, block_shape shape, block_color color);
	block(block& b);
	~block();

	void move(int x, int y);
	bool update();
	void rotate();
	bool contains(vec2& point);
	void rotate_preview();
	bool remove_point(int x, int y);

	//public data
	vec2			points[BLOCK_SIZE];
	bool			points_able[BLOCK_SIZE];
	vec2			pos;
	block_color		color;

//private:
	//
	vec2	offsets[BLOCK_SIZE];
	vec2	origin_offsets[BLOCK_SIZE];
	vec2	delay_move;
	int		delay_rotate;
	int		rotate_cycle;
	int		current_rotate;
};

typedef std::list<block*> block_list;

#endif